FROM php:7.3-fpm-alpine3.12

LABEL maintainer="test@test.com"

ENV LANG=en_US.UTF-8 \
    LANGUAGE=en_US.UTF-8 \
    LC_CTYPE=en_US.UTF-8 \
    LC_ALL=en_US.UTF-8

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
    && apk update

RUN apk add --no-cache tzdata \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 

RUN docker-php-ext-install iconv pdo_mysql bcmath

RUN apk add --no-cache libzip-dev\
    && docker-php-ext-configure zip --with-libzip=/usr/include \
    && docker-php-ext-install zip

RUN apk add --no-cache freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev \
    && docker-php-ext-configure gd  --with-png-dir=/usr/include/ \
       --with-jpeg-dir=/usr/include/ \
       --with-freetype-dir=/usr/include/ \
    && docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) gd \
    && apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev

RUN apk add --no-cache autoconf gcc g++ make \
       libmcrypt libmcrypt-dev librdkafka librdkafka-dev libmemcached libmemcached-dev \
    && pecl install https://pecl.php.net/get/mcrypt-1.0.3.tgz \
       https://pecl.php.net/get/rdkafka-4.0.3.tgz \
       https://pecl.php.net/get/xdebug-2.9.8.tgz \
       https://pecl.php.net/get/memcached-3.1.5.tgz \
       https://pecl.php.net/get/redis-5.2.2.tgz \
       #https://pecl.php.net/get/mongodb-1.7.5.tgz \
    && docker-php-ext-enable mcrypt rdkafka xdebug memcached redis\
    && apk del --no-cache autoconf gcc g++ make libmcrypt-dev librdkafka-dev libmemcached-dev

RUN mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \
    && sed -i 's/memory_limit = 128M/memory_limit = 4096M/; s/upload_max_filesize = 2M/upload_max_filesize = 200M/; s/post_max_size = 8M/post_max_size = 200M/; s/;opcache.enable=1/opcache.enable=1/; s/max_execution_time = 30/max_execution_time = 300/' /usr/local/etc/php/php.ini \
    && sed -i 's/pm.max_children = 5/pm.max_children = 50/; s/;pm.status/pm.status/' /usr/local/etc/php-fpm.d/www.conf
RUN echo -e 'xdebug.remote_enable=1\nxdebug.remote_host=host.docker.internal\nxdebug.remote_port=9000\nxdebug.idekey=PHPSTORM' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

WORKDIR /var/www/html
